#include <memory>

using namespace std;

class HeapOnly {
private:
    HeapOnly() = default;

public:
    HeapOnly(const HeapOnly&) = delete;
    HeapOnly& operator=(const HeapOnly&) = delete;

    static std::shared_ptr<HeapOnly> create() {
        return std::shared_ptr<HeapOnly>(new HeapOnly());
    }
};

int main()
{
    auto ho1 = HeapOnly::create();

    // 不能调用私有构造函数 所以不能创建栈上的对象
    // error: Calling a private constructor of class 'HeapOnly'
    // HeapOnly ho2;

    return 0;
}

